<?php
/**
 * 商户
 * User: chen guang
 * Date: 2017/9/29 9:00
 *
 */

namespace app\websys\Controller;


use think\Db;

class Down extends Common{
	
	/*
	*	构造函数
	*/
	function __construct(){
		parent::__construct();

	}

    /**
     * 下载页设置
     */
    public function Add(){
    	$about_result = db('about')->field('down_images,down_phone_images')->find();

    	if(request()->isPost()){
    		$data = array();
	      	$down_images=request()->file('down_images');
			if($down_images){
				$down_images_info = $down_images->move(ROOT_PATH . 'public' . DS . 'static' . DS . 'uploads');
				if($down_images_info){
					$data['down_images']= $down_images_info->getSaveName();
				}
			}

			$down_phone_images=request()->file('down_phone_images');
			if($down_phone_images){
				$down_phone_images_info = $down_phone_images->move(ROOT_PATH . 'public' . DS . 'static' . DS . 'uploads');
				if($down_phone_images_info){
					$data['down_phone_images']= $down_phone_images_info->getSaveName();
				}
			}

			db('about')->where(array('id'=>'1'))->update($data);
			$this->success("操作成功！");
		}

		$this->assign(array(
			'down_images'=>IMG_PATH.$about_result['down_images'],
			'down_phone_images'=>IMG_PATH.$about_result['down_phone_images'],
		));
        return $this->fetch();
    }
	
}